-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Corrections of Stream.Find, FindUntil and added FindMulti - like AVR-Core Libraries #3442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Find has some bug that is not working with Ethernet.find() so, I copied code from Stream.h and Stream.cpp in AVR-CORE library and now it's working perfectly. I don't know where was the error, but an Ethernet.find compiled to MEGA2560 was working but not working when compiled to esp32, after corrections of code (copy of AVR-Core libraries) it's working perfect. So probably has some error on original ESP32-Core library. Below is part of code that was working with MEGA2560 and not with ESP32 libraries. client.find never return TRUE with ESP32 original library and with AVR it's works. boolean esp32_fw_update(EthernetClient &client, DecodedHeader &header, const String &field_filename, const String &field_crc) { char bound[header.boundary.length()+3]; char term[]="\r\n"; strcpy(bound,header.boundary.c_str()); strcat(bound,term); while (client.find(bound)) { String line=client.readStringUntil('\r');
cores/esp32/Stream.cpp
Outdated
@@ -85,7 +85,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi | |||
unsigned long Stream::getTimeout(void) { | |||
return _timeout; | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of leaving a lot of dead code behind, just delete it.
cores/esp32/Stream.cpp
Outdated
// ******************** ALEXANDRE | ||
|
||
// find returns true if the target string is found | ||
bool Stream::find(char *target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should restore the const signatures for these methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Const signature was not there on original AVR Core code.
cores/esp32/Stream.h
Outdated
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found | ||
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); } | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here about dead code and retaining the const signature updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave this code to Espressif decide what to do. About const it was not there on original AVR Core code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless the code modifies the chars, they should be const. Regardless if that is on AVR or not :)
Find has some bug that is not working with Ethernet.find() so, I copied code from Stream.h and Stream.cpp in AVR-CORE library and now it's working perfectly.
I don't know where was the error, but an Ethernet.find compiled to MEGA2560 was working but not working when compiled to esp32, after corrections of code (copy of AVR-Core libraries) it's working perfect.
So probably has some error on original ESP32-Core library.
Below is part of code that was working with MEGA2560 and not with ESP32 libraries.
client.find never return TRUE with ESP32 original library and with AVR it's works.
boolean esp32_fw_update(EthernetClient &client, DecodedHeader &header, const String &field_filename, const String &field_crc) {
char bound[header.boundary.length()+3];
char term[]="\r\n";
strcpy(bound,header.boundary.c_str());
strcat(bound,term);
while (client.find(bound)) {
String line=client.readStringUntil('\r');